/*
 * @Author: your name
 * @Date: 2020-10-26 15:58:39
 * @LastEditTime: 2020-10-30 15:43:49
 * @LastEditors: your name
 * @Description: In User Settings Edit
 * @FilePath: \就业班练习d:\桌面\ma-pc\src\store\index.js
 */
const KEY = 'ma-heima' // 作为存值取值的key
// 存
export const setUserInfo = (info) => {
  let userInfo
  try {
    userInfo = JSON.stringify(info)
  } catch (error) {
    userInfo = ''
  }
  return localStorage.setItem(KEY, userInfo)
}
// 取
export const getUserInfo = () => {
  let formatStr
  try {
    formatStr = JSON.parse(localStorage.getItem(KEY))
  } catch (error) {
    formatStr = {}
  }
  return formatStr
}
// 删
export const delUserInfo = () => {
  // 把删除结果返回出去  如果删除失败可以通过返回值判定原因
  return localStorage.removeItem(KEY)
}
